package com.kukudexin.lockThread;

/**
 * @author: 酷酷的鑫
 * @description:
 */
public class YieldTest extends Thread {
    public YieldTest(String name) {
        super(name);
    }
    @Override
    public void run() {
        for (int i = 0; i < 50; i++) {
            if (i == 30) {
                System.out.println(Thread.currentThread().getName() + ",释放cpu执行权");
                this.yield();
            }
            System.out.println(Thread.currentThread().getName() + "," + i);
        }
    }
    public static void main(String[] args) {
        new YieldTest("mayikt01").start();
        new YieldTest("mayikt02").start();
    }
}
